package com.aiyige.page.publish.coursedescription.model;

import android.os.Parcel;
import android.os.Parcelable;

import com.aiyige.richtexteditor.model.RTEModel;
import com.aiyige.utils.widget.articleview.model.ArticleNode;

import java.util.LinkedList;
import java.util.List;

/**
 * Created by zhuyakun on 2018/3/20.
 */

public class CourseDescriptionModel implements Parcelable {
    List<CourseCover> courseCoverList;
    List<ArticleNode> articleNodeList;
    RTEModel rteModel;

    public CourseDescriptionModel() {
    }

    private CourseDescriptionModel(Builder builder) {
        setCourseCoverList(builder.courseCoverList);
        setArticleNodeList(builder.articleNodeList);
        setRteModel(builder.rteModel);
    }

    public static Builder newBuilder() {
        return new Builder();
    }

    public List<CourseCover> getCourseCoverList() {
        return courseCoverList;
    }

    public void setCourseCoverList(List<CourseCover> courseCoverList) {
        this.courseCoverList = courseCoverList;
    }

    public List<ArticleNode> getArticleNodeList() {
        return articleNodeList;
    }

    public void setArticleNodeList(List<ArticleNode> articleNodeList) {
        this.articleNodeList = articleNodeList;
    }

    public RTEModel getRteModel() {
        return rteModel;
    }

    public void setRteModel(RTEModel rteModel) {
        this.rteModel = rteModel;
    }

    public static final class Builder {
        private List<CourseCover> courseCoverList;
        private List<ArticleNode> articleNodeList;
        private RTEModel rteModel;

        private Builder() {
            courseCoverList = new LinkedList<>();
            articleNodeList = new LinkedList<>();
            rteModel = RTEModel.newBuilder().build();
        }

        public Builder courseCoverList(List<CourseCover> val) {
            courseCoverList = val;
            return this;
        }

        public Builder articleNodeList(List<ArticleNode> val) {
            articleNodeList = val;
            return this;
        }

        public Builder rteModel(RTEModel val) {
            rteModel = val;
            return this;
        }

        public CourseDescriptionModel build() {
            return new CourseDescriptionModel(this);
        }
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeTypedList(this.courseCoverList);
        dest.writeTypedList(this.articleNodeList);
        dest.writeParcelable(this.rteModel, flags);
    }

    protected CourseDescriptionModel(Parcel in) {
        this.courseCoverList = in.createTypedArrayList(CourseCover.CREATOR);
        this.articleNodeList = in.createTypedArrayList(ArticleNode.CREATOR);
        this.rteModel = in.readParcelable(RTEModel.class.getClassLoader());
    }

    public static final Creator<CourseDescriptionModel> CREATOR = new Creator<CourseDescriptionModel>() {
        @Override
        public CourseDescriptionModel createFromParcel(Parcel source) {
            return new CourseDescriptionModel(source);
        }

        @Override
        public CourseDescriptionModel[] newArray(int size) {
            return new CourseDescriptionModel[size];
        }
    };
}
